package com.tech.middle_ware.h2;

import lombok.extern.slf4j.Slf4j;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

/**
 * @author litianlin
 * @date 2023/11/23 15:12
 * @description:
 */
@Slf4j
public class H2Connect {

    public static void main(String[] args) {
        testH2Connection();
    }
    public static void testH2Connection(){
        try {
            String url = "jdbc:h2:tcp://localhost:9091/./h2";
            String username = "sa";
            String password = "";

            String driverClass = "org.h2.Driver";
            Class.forName(driverClass);
            Connection conn = DriverManager.getConnection(url, username, password);
            ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM INFORMATION_SCHEMA.USERS ");
            conn.isClosed();
        } catch (Exception e) {
            log.error("", e);
        }
    }
}
